package com.study.english.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.study.english.pojo.vo.SysUserStudyTimeVo;
import com.study.english.result.Result;
import com.study.english.service.ISysUserStudyTimeService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

import com.study.english.domain.SysUserStudyTime;

import org.springframework.web.bind.annotation.*;

/**
 * 人员学习截至时间
 *
 * @author wf
 * @description 针对表【sys_user_study_time(人员学习截至时间)】的数据库操作Controller
 * @createDate 2024-03-11 15:56:34
 */
@RestController
@RequestMapping("sysUserStudyTime")
public class SysUserStudyTimeController {

    @Autowired
    private ISysUserStudyTimeService sysUserStudyTimeService;


    /**
     * 新增:人员学习截至时间
     */
    @PostMapping("addSysUserStudyTime")
    public Result addSysUserStudyTime(@RequestBody SysUserStudyTimeVo sysUserStudyTimeVo) {
        sysUserStudyTimeService.addSysUserStudyTime(sysUserStudyTimeVo);
        return Result.success();

    }


    /**
     * 分页查询:人员学习截至时间
     */
    @PostMapping("getSysUserStudyTimePageList")
    public Result getSysUserStudyTimePageList(@RequestBody SysUserStudyTimeVo sysUserStudyTimeVo) {

        IPage<SysUserStudyTimeVo> page = new Page<>(sysUserStudyTimeVo.getPageNum(), sysUserStudyTimeVo.getPageSize());
        IPage<SysUserStudyTimeVo> list = sysUserStudyTimeService.getSysUserStudyTimePageList(page, sysUserStudyTimeVo);
        return Result.success(list);
    }


    /**
     * 不分页查询:人员学习截至时间
     */

    @PostMapping("getSysUserStudyTimeList")
    public Result getSysUserStudyTimeList(@RequestBody SysUserStudyTimeVo sysUserStudyTimeVo) {
        List<SysUserStudyTimeVo> sysUserStudyTimeVoList = sysUserStudyTimeService.getSysUserStudyTimeList(sysUserStudyTimeVo);

        return Result.success(sysUserStudyTimeVoList);
    }

    /**
     * 根据id查询详情:人员学习截至时间
     */

    @GetMapping("getSysUserStudyTimeById")
    public Result getSysUserStudyTimeById(@RequestParam String id) {
        SysUserStudyTime sysUserStudyTime = sysUserStudyTimeService.getSysUserStudyTimeById(id);
        return Result.success(sysUserStudyTime);
    }

    /**
     * 根据id删除:人员学习截至时间
     */
    @GetMapping("delSysUserStudyTime")
    public Result delSysUserStudyTime(@RequestParam String id) {
        sysUserStudyTimeService.delSysUserStudyTime(id);
        return Result.success();
    }


    /**
     * 修改:人员学习截至时间
     */
    @PostMapping("updateSysUserStudyTime")
    public Result updateSysUserStudyTime(@RequestBody SysUserStudyTimeVo sysUserStudyTimeVo) {
        sysUserStudyTimeService.updateSysUserStudyTime(sysUserStudyTimeVo);
        return Result.success();

    }

    /**
     * 查询:人员学习是否
     */
    @GetMapping("checkIsNotWatchVideo")
    public Result checkIsNotWatchVideo() {
        Boolean boo = sysUserStudyTimeService.checkIsNotWatchVideo();
        return Result.success(boo);
    }

    /**
     * 首页--看板近7天的观看时长
     */
    @GetMapping("lastSevenDay")
    public Result lastSevenDay() {
        Map<String, Object> stringObjectMap = sysUserStudyTimeService.lastSevenDay();
        return Result.success(stringObjectMap);
    }

    /**
     * 首页--看板近3年的观看时长
     */
    @GetMapping("lastThreeYear")
    public Result lastSevenYear() {
        Map<String, Object> stringObjectMap = sysUserStudyTimeService.lastThreeYear();
        return Result.success(stringObjectMap);
    }

    /**
     * 首页--看板月统计
     */
    @GetMapping("monthWatchTime")
    public Result monthWatchTime() {
        Map<String, Object> stringObjectMap = sysUserStudyTimeService.monthWatchTime();
        return Result.success(stringObjectMap);
    }

    // 4个card 统计
    @GetMapping("textDescription")
    public Result textDescription() {
        Map<String, String> stringObjectMap = sysUserStudyTimeService.textDescription();
        return Result.success(stringObjectMap);
    }

    // 近三周 统计
    @GetMapping("weekThreeWatchTime")
    public Result weekThreeWatchTime() {
        Map<String, Object> stringObjectMap = sysUserStudyTimeService.weekThreeWatchTime();

        return Result.success(stringObjectMap);
    }
}
